home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / moreosl / morememory / morememory.h < prev   
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.7 KB  |  78 lines

  1. /*
  2.     File:        MoreMemory.h
  3.  
  4.     Contains:    Memory utility routines.
  5.  
  6.     Written by:    Quinn
  7.  
  8.     Copyright:    Copyright © 1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.  
  20.          <3>     20/3/00    Quinn   Added MoreBlockCompare.
  21.          <2>      6/3/00    Quinn   Added MoreMemError and temporarily removed SafeHoldMemory from
  22.                                     Carbon builds.
  23.          <1>      1/3/99    Quinn   First checked in.
  24. */
  25.  
  26. #pragma once
  27.  
  28. /////////////////////////////////////////////////////////////////
  29. // MoreIsBetter Setup
  30.  
  31. #include "MoreSetup.h"
  32.  
  33. /////////////////////////////////////////////////////////////////
  34. // Mac OS Interfaces
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. // HoldMemory is not available to Carbon clients, even though SCSIAction
  41. // on traditional Mac OS requires you to use it.  For the moment I’ve
  42. // just made these routines CALL_NOT_IN_CARBON.  I probably should
  43. // reimplement these routines so that they call use CFM to load
  44. // the InterfaceLib versions of HoldMemory and UnholdMemory, but 
  45. // that’s not high on my priority list right now.
  46.  
  47. #if CALL_NOT_IN_CARBON
  48.  
  49. extern pascal OSErr SafeHoldMemory(void *start, ByteCount length);
  50.     // A safe version of the HoldMemory call, that does the right
  51.     // thing regardless of whether the HoldMemory trap is actually
  52.     // implemented.
  53.     //
  54.     // Note that if the system can't hold the memory because there's
  55.     // not enough physical memory, this routine will return
  56.     // notEnoughMemoryErr.
  57.  
  58. extern pascal OSErr SafeUnholdMemory(void *start, ByteCount length);
  59.     // A safe version of the HoldMemory call, that does the right
  60.     // thing regardless of whether the HoldMemory trap is actually
  61.     // implemented.
  62.  
  63. #endif
  64.  
  65. extern pascal OSErr MoreMemError(void *p);
  66.     // Returns MemError() or, if it’s noErr and p is nil,
  67.     // asserts and returns memFullErr.  The rationale for this routine
  68.     // is that some folks (interrupt-time code or patches) can clear
  69.     // MemErr unexpectedly.
  70.  
  71. extern pascal Boolean MoreBlockCompare(const void *p1, const void *p2, ByteCount numBytes);
  72.     // Compares two blocks of memory, byte for byte, return true if they are equal.
  73.     // Nice for places where you don’t want to depend on StdCLib.
  74.  
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78.